package com.qhy.springcloud.service;

import com.qhy.springcloud.api.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author qiuhongyu
 * @date 2020/10/29 17:45
 */
@Component
public class DeptclientServiceFallbackFactory implements FallbackFactory {
    public Object create(Throwable throwable) {
        return new DeptClientService() {
            public Dept queryDept(Long id) {
                Dept dept = new Dept();
                dept.setDeptno(id);
                dept.setDname("id=>" + id + "没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭了");
                dept.setDbSource("没有数据");

                return dept;
            }

            public boolean addDept(Dept dept) {
                //略
                return false;
            }

            public List<Dept> queryDepts() {
                //略
                return null;
            }
        };
    }
}
